package exam.db.dao;

import java.util.List;

import exam.db.entity.TSubQuestionEntity;
import exam.db.entity.name.TSubQuestionEntityNames;
import exam.driver.jdbc.StatementSql;
import exam.driver.jdbc.WhereComplex;

/**
 * <p>TSubQuestionDao</p>
 * <p>Thực thi các truy vấn cho TSubQuestionEntity</p>
 * @author PHONGTN
 * @version 19/4/2012
 */
public class TSubQuestionDao extends AbstractDao<TSubQuestionEntity>{
	/**
	 * Constructor
	 */
	public TSubQuestionDao() {
		super(TSubQuestionEntity.class);
	}
	/**
	 * selectAll:TSubQuestionDao
	 * @return
	 */
	public List<TSubQuestionEntity> selectAll() {
		return super.selectAll(
				TSubQuestionEntity.class,
				new StatementSql()
					.select()
					.from(TSubQuestionEntityNames.TABLE_NAME)
					.toString()
				);
	}
	/**
	 * selectByPk:TSubQuestionDao
	 * @param pk
	 * @return
	 */
	public TSubQuestionEntity selectByPk(Integer pk) {
		return super.selectByPk(
				TSubQuestionEntity.class,
				new StatementSql()
					.select()
					.from(TSubQuestionEntityNames.TABLE_NAME)
					.where(
						new WhereComplex()
							.eq(TSubQuestionEntityNames.SUB_QUEST_ID, pk))
					.toString());
	}
	/**
	 * deleteByPk:TSubQuestionDao
	 * @param arrayPk
	 * @return
	 */
	public List<Integer> deleteByPk(int[] arrayPk) {
		return super.deleteByPk(
				new StatementSql()
					.delete()
					.from(TSubQuestionEntityNames.TABLE_NAME)
					.where(
						new WhereComplex()
							.eq(TSubQuestionEntityNames.SUB_QUEST_ID))
					.toString(), arrayPk);
	}
	/**
	 * insertByFile:TSubQuestionDao
	 * @param user
	 * @return
	 */
	public int insertByFile(TSubQuestionEntity subQuest) {
		String sqlFile = "src/exam/db/dao/sql/TSubQuestionEntity_insert.sql";
		return super.insertBySqlFile(subQuest, sqlFile);
	}
	/**
	 * updateByFile:TSubQuestionDao
	 * @param params
	 * @return
	 */
	public int updateByFile(List<Object> params) {
		String sqlFile = "src/exam/db/dao/sql/TSubQuestionEntity_update.sql";
		return super.updateBySqlFile(sqlFile, params);
	}
}
